import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
    state: {
        num: 0
    },
    getters: {},
    mutations: {
        add(state) {
            state.num++;
        },
        reduce(state) {
            state.num--;
        }
    },
    actions: {
        timeAdd(context) {
            setTimeout(() => {
                context.commit('add');
            }, 2000);
        },
        timeReduce(context) {
            setTimeout(() => {
                context.commit('reduce');
            }, 2000);
        }
    },
    modules: {}
});
